package edu.tec.mty.test.ivan.playModes;

import java.util.Vector;

import edu.tec.mty.core.modules.Game;
import edu.tec.mty.core.modules.Logger;
import edu.tec.mty.core.modules.models.BallModel;
import edu.tec.mty.core.modules.models.Player;
import edu.tec.mty.core.modules.models.Position;
import edu.tec.mty.core.modules.models.WorldModel;
import edu.tec.mty.extras.Vector2D;
import edu.tec.mty.playModes.PlayMode;
import edu.tec.mty.players.PlayerActions;

public class PlayOn implements PlayMode {

	Logger logger = new Logger("world_model_", "phoenix");
	int timer = 0;
	boolean running = true;
	
	public PlayOn() {
		this.logger.start();
	}
	
	@Override
	public void perform(PlayerActions player, BallModel ballModel, WorldModel worldModel) {
		player.goTo(new Position(10.0, 0.0));
		if (Game.GAME_TIME > 0 && running) {
			Vector<Player> members = worldModel.getAllPlayers();
			if (members.size() > 0) {
//				System.out.println(Game.GAME_TIME);
				String out = "";
				for (Player pl : members) {
					out = out + pl.getID() + (pl.isViewed() ? " viewed " : " not viewed ") + pl.getCountToDeath() + " ";
				}
				this.logger.write(this, out);
			}
			if (Game.GAME_TIME > 300) {
				this.logger.shutdown();
				running = false;
			} else {
				this.timer++;
			}
		}
	}

	@Override
	public void perform(BallModel ballModel, WorldModel worldModel) {
		// TODO Auto-generated method stub
		
	}

}
